package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ExpertInfo;
import com.ruoyi.system.service.IExpertInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专家信息库Controller
 * 
 * @author ruoyi
 * @date 2025-11-10
 */
@Controller
@RequestMapping("/business/ExpertInfo")
public class ExpertInfoController extends BaseController
{
    private String prefix = "business/ExpertInfo";

    @Autowired
    private IExpertInfoService expertInfoService;

    @RequiresPermissions("business:ExpertInfo:view")
    @GetMapping()
    public String ExpertInfo()
    {
        return prefix + "/ExpertInfo";
    }

    /**
     * 查询专家信息库列表
     */
    @RequiresPermissions("business:ExpertInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ExpertInfo expertInfo)
    {
        startPage();
        List<ExpertInfo> list = expertInfoService.selectExpertInfoList(expertInfo);
        return getDataTable(list);
    }

    /**
     * 导出专家信息库列表
     */
    @RequiresPermissions("business:ExpertInfo:export")
    @Log(title = "专家信息库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ExpertInfo expertInfo)
    {
        List<ExpertInfo> list = expertInfoService.selectExpertInfoList(expertInfo);
        ExcelUtil<ExpertInfo> util = new ExcelUtil<ExpertInfo>(ExpertInfo.class);
        return util.exportExcel(list, "专家信息库数据");
    }

    /**
     * 新增专家信息库
     */
    @RequiresPermissions("business:ExpertInfo:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存专家信息库
     */
    @RequiresPermissions("business:ExpertInfo:add")
    @Log(title = "专家信息库", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ExpertInfo expertInfo)
    {
        return toAjax(expertInfoService.insertExpertInfo(expertInfo));
    }

    /**
     * 修改专家信息库
     */
    @RequiresPermissions("business:ExpertInfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ExpertInfo expertInfo = expertInfoService.selectExpertInfoById(id);
        mmap.put("expertInfo", expertInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存专家信息库
     */
    @RequiresPermissions("business:ExpertInfo:edit")
    @Log(title = "专家信息库", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ExpertInfo expertInfo)
    {
        return toAjax(expertInfoService.updateExpertInfo(expertInfo));
    }

    /**
     * 删除专家信息库
     */
    @RequiresPermissions("business:ExpertInfo:remove")
    @Log(title = "专家信息库", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(expertInfoService.deleteExpertInfoByIds(ids));
    }
}
